package cn.school.logistics.service.impl;

import cn.school.logistics.dao.AssetsCategoryDao;
import cn.school.logistics.entity.AssetsCategory;
import cn.school.logistics.service.AssetsCategoryService;
import cn.school.logistics.vo.AssetsCategoryTreeNode;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * @className: AssetsCategoryServiceImpl
 * @author: fangjin.tao
 * @date: 2022/12/8
 **/
@Service
public class AssetsCategoryServiceImpl extends ServiceImpl<AssetsCategoryDao, AssetsCategory> implements AssetsCategoryService {
	@Override
	public List<AssetsCategoryTreeNode> getAll() {
		LambdaQueryWrapper<AssetsCategory> queryWrapper = new LambdaQueryWrapper<>();
		queryWrapper.orderByAsc(AssetsCategory::getAscaParentId, AssetsCategory::getId);
		List<AssetsCategory> assetsCategoryList = this.baseMapper.selectList(queryWrapper);
		
		List<AssetsCategoryTreeNode> treeNodeList = this.processTreeNodeBiz(assetsCategoryList);
		
		return treeNodeList;
	}
	
	/**
	 * 转换成树结点
	 *
	 * @throws
	 * @author fangjin.tao
	 * @param: assetsCategoryList
	 * @updateTime 2022/12/10 9:44
	 * @return: java.util.List<cn.school.logistics.vo.AssetsCategoryTreeNode>
	 */
	private List<AssetsCategoryTreeNode> processTreeNodeBiz(List<AssetsCategory> assetsCategoryList) {
		List<AssetsCategoryTreeNode> treeNodes = new ArrayList<>();
		
		// FIXME 暂时先不用
		
		
		return  treeNodes;
	}
}
